package com.ruoyi.web.controller.material;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.material.domain.SmesMaterialOutInBillDetail;
import com.ruoyi.mes.material.service.ISmesMaterialOutInBillDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 原料出入库订单明细管理Controller
 *
 * @author simpsense
 * @date 2020-12-16
 */
@RestController
@RequestMapping("/material/materialOutInBilldetail")
public class SmesMaterialOutInBillDetailController extends BaseController
{
    @Autowired
    private ISmesMaterialOutInBillDetailService smesMaterialOutInBillDetailService;

    /**
     * 查询原料出入库订单明细管理列表
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmesMaterialOutInBillDetail smesMaterialOutInBillDetail)
    {
        startPage();
        List<SmesMaterialOutInBillDetail> list = smesMaterialOutInBillDetailService.selectSmesMaterialOutInBillDetailList(smesMaterialOutInBillDetail);
        return getDataTable(list);
    }

    /**
     * 导出原料出入库订单明细管理列表
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:export')")
    @Log(title = "原料出入库订单明细管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmesMaterialOutInBillDetail smesMaterialOutInBillDetail)
    {
        List<SmesMaterialOutInBillDetail> list = smesMaterialOutInBillDetailService.selectSmesMaterialOutInBillDetailList(smesMaterialOutInBillDetail);
        ExcelUtil<SmesMaterialOutInBillDetail> util = new ExcelUtil<SmesMaterialOutInBillDetail>(SmesMaterialOutInBillDetail.class);
        return util.exportExcel(list, "materialOutInBilldetail");
    }

    /**
     * 获取原料出入库订单明细管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:query')")
    @GetMapping(value = "/{rowId}")
    public AjaxResult getInfo(@PathVariable("rowId") Long rowId)
    {
        return AjaxResult.success(smesMaterialOutInBillDetailService.selectSmesMaterialOutInBillDetailById(rowId));
    }

    /**
     * 新增原料出入库订单明细管理
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:add')")
    @Log(title = "原料出入库订单明细管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmesMaterialOutInBillDetail smesMaterialOutInBillDetail)
    {
        return toAjax(smesMaterialOutInBillDetailService.insertSmesMaterialOutInBillDetail(smesMaterialOutInBillDetail));
    }

    /**
     * 修改原料出入库订单明细管理
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:edit')")
    @Log(title = "原料出入库订单明细管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmesMaterialOutInBillDetail smesMaterialOutInBillDetail)
    {
        return toAjax(smesMaterialOutInBillDetailService.updateSmesMaterialOutInBillDetail(smesMaterialOutInBillDetail));
    }

    /**
     * 删除原料出入库订单明细管理
     */
    @PreAuthorize("@ss.hasPermi('material:materialOutInBilldetail:remove')")
    @Log(title = "原料出入库订单明细管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{rowIds}")
    public AjaxResult remove(@PathVariable Long[] rowIds)
    {
        return toAjax(smesMaterialOutInBillDetailService.deleteSmesMaterialOutInBillDetailByIds(rowIds));
    }
}